<?php
/* @var $this ServiceController */
/* @var $model Service */

$this->breadcrumbs = array(
    'Services' => array('index'),
    $model->name,
);

$this->menu = array(
    array('label' => 'List Service', 'url' => array('index')),
    array('label' => 'Create Service', 'url' => array('create')),
    array('label' => 'Update Service', 'url' => array('update', 'id' => $model->id)),
    array('label' => 'Delete Service', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')),
    array('label' => 'Manage Service', 'url' => array('admin')),
);
?>

<h1>  <?php echo $model->name; ?></h1>

<?php
$this->widget('zii.widgets.CDetailView', array(
    'data' => $model,
    'attributes' => array(
        'name',
        'dese',
        'price',
        'img',
        'duration',
        'isActive',
    ),
));
?>

<div style="margin-top:20px;color:#666">
    <h3>Add Tools to Service</h3>
    <?php
    if (isset($availTools)) {
        echo '<form id="service_tool_form" method="post" action="' . CController::createUrl('Service/addToolToService') . '">';
        
        echo '<select name="item_id" class="cmn_input_drp w300">';
        foreach ($availTools as $key => $value) {
            echo '<option value="' . $value->id . '">' . $value->name . '</option>';
        }
        echo '</select>';
    }
    echo '<input type="input" name="no_item" placeholder="No. of item" class="cmn_input ml10"/>';
    echo '<input type="hidden" name="service_id" value="' . $model->id . '"/>';
    echo '<input type="submit" value="+" class="cmn_add"/>';
    echo '</form>';
    ?>
	<div style="margin-top:20px;color:#666">
 <?php
    if (isset($tools)) {
        echo '<table class="cmn_table" ><tr><td>Item Name</td><td>No. of Item</td><td></td></tr>';
        foreach ($tools as $key => $value) {
            echo '<tr><td>' . $value->item->name . '</td><td>' . $value->no_item . '</td><td><a href="'.CController::createUrl('Service/deleteTool').'?id='.$value->id.'">Delete</a></td></tr>';	
        }
        echo '</table>';
    }
    ?>
	</div>
</div>
<div style="margin-top:20px;color:#666">


    <h3>Who all are doing : <?php echo $model->name; ?></h3>
	  <?php
    if (isset($users)) {
        echo '<form id="service_tool_form" method="post" action="' . CController::createUrl('Service/addResource') . '">';
        ;
        echo '<select name="resource_id" class="cmn_input_drp">';
        foreach ($users as $key => $value) {
            echo '<option value="' . $value->id . '">' . $value->username . '</option>';
        }
        echo '</select>';
        echo '<input type="hidden" name="service_id" value="' . $model->id . '"/>';
        echo '<input type="submit" value="+" class="cmn_add"/>';
        echo '</form>';
    }
    ?>
    <?php
    if(isset($resources)){
         echo '<table class="cmn_table" ><tr><td>Employee Name</td><td>User Name</td><td></td></tr>';
        foreach ($resources as $key => $value) {
             echo '<tr><td>' . $value->resources->profile->name . '</td><td>' . $value->resources->username. '</td><td><a href="'.CController::createUrl('Service/deleteResource').'?id='.$value->id.'">Delete</a></td></tr>';	
        }
        echo '</table>';
    }
    ?>
  
</div>

